@extends('layouts.default')
@section('content')
<div class="request">
	<div class="tab-control">
		<div class="pending-tab title tab {{$historyTabSelected ? '': 'selected'}}"><a href="#" class="">Solicitudes pendientes</a></div>
		<div class="solved-tab title tab {{$historyTabSelected ? 'selected': ''}}"><a href="#" class="">Historial de Solicitudes</a></div>
	</div>
	<div class="pending">
		<div class="contents">
			@if($pendingRequests->isEmpty())
			<p>Usted no tiene solicitudes pendientes por resolver.</p>
			@else
			<table class="table pending requests-table">
				<thead>
					<tr>
						<th>Fecha de creación</th>
						<th>Fecha de actualización</th>
						<th>Usuario</th>
						<th>Estado</th>
						<th colspan="3">Acciones</th>
					</tr>
				</thead>
				<tbody>
			     @foreach($pendingRequests as $request)
			     	<tr id="{{$request->pk}}">
			     		<td>{{$request->created_at->format(Config::get('globals.dateFormatStr'))}}</td>
			     		<td>{{$request->updated_at->format(Config::get('globals.dateFormatStr'))}}</td>
			     		<td>{{$request->requestedBy->name." ".$request->requestedBy->first_lastname}}</td>
			     		<td>{{$request->requestStatus->description}}</td>
			     		<td><a class="btn items-show" href="#">Ver items</a></td>
			     	</tr>
			     @endforeach
		     	</tbody>
		     </table>
		     @endif
		</div>
 	</div>
 	<div class="solved hidden">
 		<div class="requests-filter">
			<div class="heading">Filtros</div>
			<div class="fields">
				<div class="from">
					<label class="label">Desde: </label><input type="date" />
				</div>
				<div class="to">
					<label class="label">Hasta: </label><input type="date" />
				</div>
				<div class="users">
					<label class="label">Usuario: </label>
					<select>
						<option value="">--</option>
						@foreach($users as $user)
							<option value="{{$user->pk}}">{{$user->getFullName()}}</option>
						@endforeach
					</select>
				</div>
				<div class="controls">
					<a href="#">Buscar</a>
				</div>
			</div>
		</div>
 		<div class="contents">
		    @if($solvedRequests->isEmpty())
			<p>El historial de solicitudes está vacío.</p>
			@else
			<table class="table solved requests-table">
				<thead>
					<tr>
						<th>Fecha de creación</th>
						<th>Fecha de actualización</th>
						<th>Usuario</th>
						<th>Estado</th>
						<th colspan="3">Acciones</th>
					</tr>
				</thead>
				<tbody>
			     @foreach($solvedRequests as $request)
			     	<tr id="{{$request->pk}}">
			     		<td>{{$request->created_at->format(Config::get('globals.dateFormatStr'))}}</td>
			     		<td>{{$request->updated_at->format(Config::get('globals.dateFormatStr'))}}</td>
			     		<td>{{$request->requestedBy->name." ".$request->requestedBy->first_lastname}}</td>
			     		<td>{{$request->requestStatus->description}}</td>
			     		<td><a class="btn items-show" href="#">Ver items</a></td>
			     	</tr>
			     @endforeach
		     	</tbody>
		     </table>
		     {{$solvedRequests->links()}}
		     @endif
	 	</div>
	</div>
     <div class="request-options">
     	<a href="#" class="btn create">Crear una solicitud</a>
     </div>
</div>
     {{ HTML::style('css/popup.css'); }}
     <script type="text/javascript" src="js/RequestsAdmin.js"></script>
@stop